#include <stdio.h>

int main(int argc, char *argv[])
{

    int n, m, k;
    scanf("%d", &n);
    for (size_t i = 0; i < n; i++)
    {
        scanf("%d %d", &m, &k);
        int sum = 0;
        for (size_t i = 1; i < m; i++)
        {
            if (m % i == 0)
                sum += i;
        }
        if(sum==k){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }

    return 0;
}